package com.itheima.d3_inner_class3;

/*
    1 匿名内部类在开发中的使用场景
        通常作为一个参数传输给方法。

 */
public class Test2 {
    public static void main(String[] args){
        Swimming s1 = new Swimming(){
            public void swim(){
                System.out.println("狗刨飞快");
            }
        };
        go(s1);

        Swimming s2 = new Swimming(){
            public void swim(){
                System.out.println("猴子游泳也还行");
            }
        };
        go(s2);
    }
    //形参是Swimming接口，实参可以接收任意Swimming接口的实现类对象
    public static void go(Swimming s){
        System.out.println("开始~~~~~~~~");
        s.swim();
        System.out.println("结束~~~~~~~~");
    }
    }

    interface Swimming {
        public void swim();
    }
